using System;
using System.Data;
using MySql.Data.MySqlClient;

namespace hemsidan.DataAccess
{
	/// <summary>
	/// Summary description for DB.
	/// </summary>
	public abstract class DB
	{
		public const String DBTYPE_ACCESS = "Access";
		public const String DBTYPE_MYSQL = "MySQL";

		protected static DB myDB;

		public static DB getInstance()
		{
			if (myDB == null)
			{
				if (Helpers.Settings.DBType.Equals(DBTYPE_MYSQL))
				{
					myDB = new DBMySQL();
				}
				else if (Helpers.Settings.DBType.Equals(DBTYPE_ACCESS))
				{
					myDB = new DBAccess();
				}
				else 
				{
					throw new SystemException("No DB type defined");
				}
			}
			return myDB;
		}

		public abstract DataSet ExecuteDataSet(string sql);
		

		public abstract void ExecuteNonQuery(string sql);
	}
}
